const empty = (req, res) => {
    res.status(404).send({
      code: 404,
      message: '你请求的路径地址不存在, 有可能是地址错了, 有可能是请求方式错了',
      tips: {
        url: req.url,
        method: req.method
      }
    })
  }
  
const info = (req, res, next) => {
    console.log(`
    当前服务器接收到了一个请求
    事件：${new Date()}
    请求方式：${req.method}
    请求地址：${req.url}
    请求参数：${JSON.stringify(req.query)}  
    请求params：${JSON.stringify(req.params)}
    请求body：${JSON.stringify(req.body)}
    `);
    next()

}
const error = (err, req, res, next) => {
    if(err===4)return res.send({
        code:4,
        massage:'参数不全，请查证后再试',
        query:req.query,
        params:req.params,
        body:req.body,
    })
    if(err===5)return res.send({
        code:5,
        massage:'参数格式不对,请查证后再试',
        query:req.query,
        params:req.params,
        body:req.body,
    })

}
module.exports = {
    empty,
    error,
    info
}